home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11758 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.sunquest.com!kitk!kitk
  2. From: kitk@mudshark.sunquest.com (Kit Kauffmann)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Instantiate Forward Declared Class
  5. Date: Fri, 15 Mar 1996 14:35:45
  6. Organization: Sunquest
  7. Message-ID: <kitk.2137.000E9904@mudshark.sunquest.com>
  8. References: <DoAu1u.Lxx@news.uwindsor.ca>
  9. NNTP-Posting-Host: kkauffma.sunquest.com
  10. Keywords: Forward declaration
  11. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  12.  
  13. In article <DoAu1u.Lxx@news.uwindsor.ca> saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g) writes:
  14. >From: saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g)
  15. >Subject: Instantiate Forward Declared Class
  16. >Keywords: Forward declaration
  17. >Date: Fri, 15 Mar 1996 07:56:17 GMT
  18.  
  19. >Hi All,
  20.  
  21. >--- How do you instantiate a class that has not yet been defined but has been
  22. >    forward declared?
  23.  
  24. >e.g. how do you implement the following:
  25.  
  26. >class A { public : AMethod(B bObj){}; };
  27. >class B { public : BMethod(A aObj){}; };
  28.  
  29. >compiling this will result in an error message telling that A and B are not known.
  30. >But when froward declaring A and B as in "class A; class B;" before the two lines
  31. >above, the error message becomes: parameters bObj and aObj are incomplete types.
  32.  
  33. >Apparently it is not possible to instantiate a declared but not yet defined class.
  34.  
  35. >The answer to this question will also answer my previous question (143815)
  36. >From saed@engn.uwindsor.ca
  37. >Subject: error: undef. but decl. template as member
  38. >Date: Wed, 13 Mar 1996 02:14:38 GMT
  39.  
  40. >Thanks in advance,
  41. >Aryan.
  42.  
  43.  
  44. Of course you can't - the compiler doesn't know how big the object is.  But 
  45. you can always use pointers to "unknown" objects to solve problems like this 
  46. (AFAIK :)
  47.  
  48. HTH!
  49.  
  50.  
  51. Kit Kauffmann - kitk@mudshark.sunquest.com
  52. AKA 73363,447 (Compu$erve)
  53.  
  54. Finger me for my public key
  55.